import axios from 'axios';
import router from "../router";
import { ElMessage } from "element-plus";

let baseURL = ""
const service = axios.create({
    // process.env.NODE_ENV === 'development' 来判断是否开发环境
    baseURL: baseURL,
    timeout: 10000
});

service.interceptors.request.use(
    config => {
        return config;
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);

service.interceptors.response.use(
    response => {
        if(response.status === 200) {
            return response.data
        }else {
            return Promise.reject(response.statusText)
        }
    },
    error => {
        return Promise.reject(error)
    }
);

export default service;
